// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
import "../Components"

AndroidItem {
    id: _root

    property int numberOfHomescreen: 5

    signal clicked(int key)
    signal startApplication(string packageName)

    //上側のグラデーション
    Rectangle{
        anchors.top: parent.top
        anchors.left: parent.left
        anchors.right: parent.right
        height: 100 * viewScale
        gradient: Gradient {
             GradientStop { position: 0.0; color: "#33000000" }
             GradientStop { position: 1.0; color: "#00000000" }
        }
    }
    //下側のグラデーション
    Rectangle{
        anchors.bottom: parent.bottom
        anchors.left: parent.left
        anchors.right: parent.right
        height: 160 * viewScale
        gradient: Gradient {
             GradientStop { position: 0.0; color: "#00000000" }
             GradientStop { position: 1.0; color: "#88000000" }
        }
    }

    property real activeBarPosition: 0.5
    function showActiveBar(){
        if(_activeBarAnim.running === true){
            _activeBarAnim.stop();
        }
        _activeBar.opacity = 1.0;
    }
    function hideActiveBar(){
        if(_activeBarAnim.running === false){
            _activeBarAnim.start();
        }
    }

    Column{
        anchors.left: parent.left
        anchors.right: parent.right
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 20 * viewScale
        spacing: 10

        //バー
        Image{
            anchors.horizontalCenter: parent.horizontalCenter
//            x: 11 * viewScale
//            y: 961 * viewScale
            width: 698 * viewScale
            height: 12 * viewScale
            source: "images/home_bar.png"
            smooth: true
            //アクティブ
            Image{
                id: _activeBar
                x: (parent.width - width) * activeBarPosition
                y: 4 * viewScale
                width: parent.width / _root.numberOfHomescreen
                height: 4 * viewScale
                source: "images/home_bar_viewing.png"
                smooth: true
                opacity: 0
                onXChanged: {
    //                opacity = 1.0;
                }
                NumberAnimation{
                    id: _activeBarAnim
                    target: _activeBar
                    running: false
                    property: "opacity"
                    to: 0
                    duration: 1000
                }
            }
        }

        //ショートカットボタン
        Row{
            anchors.horizontalCenter: parent.horizontalCenter

            //ダイヤル
            ImageButton{
                anchors.verticalCenter: parent.verticalCenter
                width: 96 * viewScale
                height: 96 * viewScale
                imageIdle: "../Android/Applications/images/ic_launcher_phone.png"
                imagePress: "../Android/Applications/images/ic_launcher_phone.png"
                onClicked: {
                    _root.startApplication("com.android.phone");
                }
            }
            Item{
                width: 14
                height: 1
            }
            //JcBeam
            ImageButton{
                anchors.verticalCenter: parent.verticalCenter
                width: 96 * viewScale
                height: 96 * viewScale
                imageIdle: "../Android/Applications/images/ComJcromJcbeam/ic_launcher.png"
                imagePress: "../Android/Applications/images/ComJcromJcbeam/ic_launcher.png"
                onClicked: {
                    _root.startApplication("com.jcrom.jcbeam");
                }

            }
            //コンタクト
    //        ImageButton{
    //            anchors.verticalCenter: parent.verticalCenter
    //            width: 96 * viewScale
    //            height: 96 * viewScale
    //            imageIdle: "../Android/Applications/images/ic_launcher_contacts.png"
    //            imagePress: "../Android/Applications/images/ic_launcher_contacts.png"
    //        }
            Item{
                width: 10
                height: 1
            }
            //ランチャー起動ボタン
            ImageButton{
                width: 120 * viewScale
                height: 120 * viewScale
                imageIdle: "../Android/images/launcher_button.png"
                imagePress: "../Android/images/launcher_button_pressed.png"

                onClicked: {
                    _root.clicked(1);
                }
            }
            Item{
                width: 10
                height: 1
            }
            //SMS
            ImageButton{
                anchors.verticalCenter: parent.verticalCenter
                width: 96 * viewScale
                height: 96 * viewScale
                imageIdle: "../Android/Applications/images/ic_launcher_smsmms.png"
                imagePress: "../Android/Applications/images/ic_launcher_smsmms.png"
            }
            Item{
                width: 14
                height: 1
            }
            //ブラウザ
            ImageButton{
                anchors.verticalCenter: parent.verticalCenter
                width: 96 * viewScale
                height: 96 * viewScale
                imageIdle: "../Android/Applications/images/ic_launcher_browser.png"
                imagePress: "../Android/Applications/images/ic_launcher_browser.png"
            }
        }
    }


}
